package com.example.controller;


import com.example.common.annotation.OperLog;
import com.example.common.enums.LogType;
import com.example.common.utils.R;
import com.example.system.entity.AppointmentScheduler;
import com.example.system.service.IAppointmentSchedulerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDate;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 王鹤蒲
 * @since 2024-01-29
 */
@Api(tags = "医生排班信息API",description="医生排班信息相关的 REST API")
@RestController
@RequestMapping("/appointment-scheduler")
public class AppointmentSchedulerController {

    @Autowired
    private IAppointmentSchedulerService iAppointmentSchedulerService;


    @ApiOperation(value = "",notes = "")
    @OperLog(operation = "医生排班管理",type = LogType.ADD)
    @RequestMapping(value="/save",method=RequestMethod.POST)
    @ResponseBody
    public R insert(@RequestBody AppointmentScheduler appointmentScheduler){
        return iAppointmentSchedulerService.insert(appointmentScheduler);
    }


    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/selectAll",method= RequestMethod.GET)
    @ResponseBody
    public R selectAll(@RequestParam Integer currentPage, @RequestParam Integer pageSize, @RequestParam(defaultValue = "") Integer doctorId, @RequestParam(defaultValue = "") Integer departmentId, @RequestParam(defaultValue = "") @DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate workDate, @RequestParam(defaultValue = "") String dayPart, @RequestParam(defaultValue = "") String status){
        return iAppointmentSchedulerService.selectAll(currentPage,pageSize,doctorId,departmentId,workDate,dayPart,status);
    }


    @OperLog(operation = "医生排班管理",type = LogType.DELETE)
    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/delete/{id}",method= RequestMethod.DELETE)
    @ResponseBody
    public R deleteById(@PathVariable("id") Integer id) {
        return iAppointmentSchedulerService.deleteById(id);
    }


    @OperLog(operation = "医生排班管理",type = LogType.BATCH_DELETE)
    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/deleteBatch",method= RequestMethod.POST)
    @ResponseBody
    public R deleteByIds(@RequestBody Integer[] ids) {
        return iAppointmentSchedulerService.deleteByIds(ids);
    }


    @OperLog(operation = "医生排班管理",type = LogType.UPDATE)
    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/edit",method= RequestMethod.POST)
    @ResponseBody
    public R edit(@RequestBody AppointmentScheduler appointmentScheduler) {
        return iAppointmentSchedulerService.edit(appointmentScheduler);
    }


    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/getDepartmentAppointmentSchedulerInfos",method = RequestMethod.GET)
    @ResponseBody
    public R getDepartmentAppointmentSchedulerInfos(@RequestParam Integer currentPage, @RequestParam Integer pageSize, @RequestParam Integer departmentId){
        return iAppointmentSchedulerService.getDepartmentAppointmentSchedulerInfos(currentPage,pageSize,departmentId);
    }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value="/getDepartmentAppointmentScheduler",method = RequestMethod.GET)
    @ResponseBody
    public R getDepartmentAppointmentScheduler(@RequestParam Integer departmentId,@RequestParam String startDate, @RequestParam String  endDate){
        return iAppointmentSchedulerService.getDepartmentAppointmentScheduler(departmentId,startDate,endDate);
    }


    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/selectAppointmentSchedulerDetailInfos",method=RequestMethod.GET)
    @ResponseBody
    public R selectAppointmentSchedulerDetailInfos(@RequestParam Integer departmentId, @RequestParam String workDate){
        return iAppointmentSchedulerService.selectAppointmentSchedulerDetailInfos(departmentId,workDate);
    }


    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/getAppointmentTimeList/{appointmentSchedulerId}",method=RequestMethod.GET)
    @ResponseBody
    public R getAppointmentTimeList(@PathVariable("appointmentSchedulerId") Integer appointmentSchedulerId){
        return iAppointmentSchedulerService.getAppointmentTimeList(appointmentSchedulerId);
    }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/suspend",method=RequestMethod.GET)
    @ResponseBody
    public R suspend(@RequestParam Integer appointmentSchedulerId,@RequestParam String suspendReason){
        return iAppointmentSchedulerService.suspend(appointmentSchedulerId,suspendReason);
    }

    @ApiOperation(value = "", notes = "")
    @RequestMapping(value = "/selectSuspendNoticeList",method=RequestMethod.GET)
    @ResponseBody
    public R selectSuspendNoticeList() {
        return iAppointmentSchedulerService.selectSuspendNoticeList();
    }
}

